#ifndef CIVIEW_FEEDBACKTRANSLATION_H
#define CIVIEW_FEEDBACKTRANSLATION_H

#include "../Core/Matrix.h"
#include "../Geometries/Geometry.h"
#include "Camera.h"
#include "Scene.h"

namespace CIView {
    class FeedbackTranslation {
    /**
     * This class includes all data needed to draw the feedback for 
     * a translation of the primitives selected   
     **/

        static const float ARROWHEAD_RADIUS;

    public:
        FeedbackTranslation();              //Constructor
        virtual ~FeedbackTranslation();     //Destructor

        //Used as names for the axes in the OpenGL names stack
        enum {
            X_AXIS
          , Y_AXIS
          , Z_AXIS
          , ALL_AXES
        };

    protected:
        GLUquadric* quadricObj;                 //A pointer to an OpenGL quadric object, used to draw the feedback
        
        CIGeom::Box centralBox;                 //The box to select all axes of the feedback

        CIGeom::Box x_axisBoundingBox;          //The bounding box of the x-axis (used for axes selection)
        CIGeom::Box y_axisBoundingBox;          //The bounding box of the y-axis (used for axes selection)
        CIGeom::Box z_axisBoundingBox;          //The bounding box of the z-axis (used for axes selection)

        bool x, y, z;                           //Booleans to indicate which axes are selected
        CICore::Point position;                 //The position of the feedback
        CICore::Point ghostPosition;            //The position of the "ghost" shown as feedback during the translation operation
        
        bool renderizable;                      //A boolean to indicate if the feedback can be rendered

        void DrawGhostFeedback (Camera& camera);       //Method called to draw the "ghost" feedback while necessary
        void DrawArrow();

    public:     
        //Utility Methods
        void Init();                                    //Method called to initialize the feedback object
        void ComputeFeedbackPosition (Scene& scene);    //Method called to compute the feedback position

        //Methods to select/deselect the axes of the feedback
        void SelectX();
        void SelectY();
        void SelectZ();
        void SelectAll();
        void DeselectAll();

        bool IsSelectedX();
        bool IsSelectedY();
        bool IsSelectedZ();

        void LockInitialPosition();                     //Method called to lock the initial position during the translation operation, to show the "ghost" feedback

        void ApplyMatrix (const CICore::Matrix& m);     //Method called to apply a matrix transformation to the feedback position

        void Render (Camera& camera);                   //Method called to draw the translation feedback
        void LoadAxesNames (Camera& camera);            //Method called to load the names for the axes in the OpenGL names stack       
    };
}

#endif /* CIVIEW_FEEDBACKTRANSLATION_H */
